package com.nut.dao.impl;

import com.nut.dao.OrderItemDao;
import com.nut.pojo.OrderItem;

import java.util.List;

public class OrderItemDaoImpl extends BaseDao implements OrderItemDao {
    @Override
    public int SaveOrderItem(OrderItem orderItem) {
        String sql = "insert into t_order_item(`name`,`price`,`total_money`,`count`,`order_id`)values(?,?,?,?,?)";
        return update(sql,orderItem.getName(),orderItem.getPrice(),orderItem.getTotalPrice(),orderItem.getCount(),orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItem(String orderId) {
        String sql = "select `name` name ,`price` price ,`total_money` totalPrice ,`count` count  from t_order_item where `order_id` = ?";
        return queryForList(OrderItem.class,sql,orderId);
    }
}
